@extends('layout.adminlayout')
@section('css')
<script src="/admin/js/metisMenu.min.js"></script>
<script src="/admin/js/custom.js"></script>
<link href="/admin/css/custom.css" rel="stylesheet">
@endsection
@section('content')
<div class="tables">
	<div class="table-responsive bs-example widget-shadow">
		<h4 style="margin-bottom: 15px;">客户列表 :</h4>
		<form action="/admin/user/index" method="get">
			<div class="row" style="padding-bottom: 15px;margin-top: 0px;">
				<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">代理商：</p>
				<select name="ag" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 15%;">
					<option value="">请选择代理商</option>
					@foreach($agent as $v)
						<option value="{{$v['id']}}"
								@if($get['ag'] == $v['id'])
								selected
								@else
								@if(Cookie::get('agentId') == $v['id'])
								selected
								@endif
								@endif>{!! $v['agent_name'] !!}</option>
					@endforeach
				</select>
				<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">用户名：</p>
				<input type="text" name="name" value="{{$name}}" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 15%;"/>
				<p class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="width: 70px; height: 32px;padding: 0px;text-align: right;line-height: 32px;">手机号：</p>						
				<input type="text" name="phone" id="" value="{{$phone}}" class="col-lg-1 col-md-1 col-sm-1 col-xs-1" style="height: 30px; line-height: 30px; padding: 0px; border: 1px solid #DDD; margin: 0px 10px; width: 15%;"/>
				<input type="submit" value="搜索" class="col-lg-1 col-md-1 col-sm-1 col-xs-1"  style="height: 30px; line-height: 32px; padding: 0px; border: 0; background: #4F52BA;width: 50px; margin: 0px 10px;color:#fff"/>	
			</div>
		</form>
		<table class="table table-bordered" >
			<thead>
 				<tr>
					<th style="text-align: center">用户编号</th>
					<th style="text-align: center">用户名称</th>
					<th style="text-align: center">管理范围</th>
					<th style="text-align: center">手机号</th>
					<th style="text-align: center">固定电话</th>
					<th style="text-align: center">邮箱</th>
					<th style="text-align: center">微信</th>
					@if($get['ag'] == Cookie::get('agentId'))
					<th style="text-align: center">操作</th>
					@endif
				</tr>
			</thead>
			<tbody>
			@if(!null==$info)
				@foreach($info as $v)
					<tr> 
						<th scope="row" style="text-align: center">{{$v['uid']}}</th>
						<td style="text-align: center">{{$v['username']}}</td>
						<td style="text-align: center">
							@if($v['row'] != null)
								@foreach($v['row'] as $val)
									@if($val['mma_a_id'] != 0 &&$val['mma_b_id'] == 0 &&$val['mma_r_id'] == 0 && $val['a_name'] != null )
										区域:{{$val['a_name']}}
									@elseif($val['mma_a_id'] != 0 &&$val['mma_b_id'] != 0 &&$val['mma_r_id'] == 0 && $val['b_name'] != null)
										建筑:{{$val['b_name']}}
									@elseif($val['mma_a_id'] != 0 &&$val['mma_b_id'] != 0 &&$val['mma_r_id'] != 0 && $val['r_name'] != null)
										房间:{{$val['r_name']}}
									@endif
								@endforeach
							@endif
						</td>
						<td style="text-align: center">{{$v['mobile']}}</td>
						<td style="text-align: center">{{$v['telephone']}}</td>
						<td style="text-align: center">{{$v['email']}}</td>
						<td style="text-align: center">{{$v['weChat']}}</td>
						@if($get['ag'] == Cookie::get('agentId'))
						<td style="text-align: center"><a href="/admin/user/edit?uid={{$v['uid']}}">编辑</a>&nbsp;|&nbsp;<a href="/admin/user/delete?id={{base64_encode($v['uid'])}}">删除</a></td>
						@endif
					</tr>
				@endforeach
			@endif
			</tbody> 
		</table>
		@if(!null == $user)
			<div style="float:right;">
				{!! $user->appends($request)->render() !!}
			</div>
		@endif
	</div>
</div>
@endsection